package com.canal.admin.controller;

import com.canal.admin.entity.SysUser;
import com.canal.admin.response.ResultUtil;
import com.canal.admin.response.Result;
import com.canal.admin.transfer.resp.UserResp;
import com.canal.admin.util.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangbo
 * @Date 2019-03-18 14:43
 */
@RestController
public class UserController {


    /**
     * 用户基本信息
     * @return
     */
    @GetMapping(value = "/info")
    @PreAuthorize("isAuthenticated()")
    public Result userInfo() {
        SysUser sysUser = SecurityUtils.currentUser();
        UserResp userResp = new UserResp();
        userResp.setName(sysUser.getName());
        userResp.setAvatar(sysUser.getAvatar());
        return ResultUtil.makeSuccess(userResp);
    }


}
